package com.nengchuan.eic.nceconomy.controller;

import com.eic.review.sdk.vo.IndividualProjectInfoVo;
import com.eic.review.sdk.vo.ProjectInfoVo;
import com.github.pagehelper.PageInfo;
import com.nengchuan.eic.nceconomy.entity.dto.ExcelDetailDTO;
import com.nengchuan.eic.nceconomy.entity.dto.ProjectDTO;
import com.nengchuan.eic.nceconomy.entity.vo.IndividualProjectInfoVO;
import com.nengchuan.eic.nceconomy.entity.vo.ProjectVO;
import com.nengchuan.eic.nceconomy.service.ProjectService;
import com.nengchuan.model.model.WrappedResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 功能描述:
 *
 * @Author: liurui
 * @Date: 2020/4/26 0026 上午 10:47
 */
@RestController
@RequestMapping("/api/project")
@Api(value = "ProjectController", tags = "项目信息")
public class ProjectController {

    @Autowired
    private ProjectService projectService;


    @ApiOperation("查询输变电工程列表（带条件查询）")
    @PostMapping(value = "/power_transmission_and_transformation", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiResponse(code = 200, message = "成功为true,失败为false", response = WrappedResult.class)
    public WrappedResult<ProjectVO> getList(@RequestBody ProjectDTO projectDTO) {
        return WrappedResult.success(projectService.getList(projectDTO));
    }

    @ApiOperation("查询输变电工程子工程")
    @GetMapping(value = "/project_detail_list", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiResponse(code = 200, message = "成功为true,失败为false", response = WrappedResult.class)
    public WrappedResult<List<IndividualProjectInfoVO>> getDetailList(@RequestParam("projectId") Long projectId) {
        return projectService.getDetailList(projectId);
    }

    @ApiOperation("查询输变电工程子工程")
    @GetMapping(value = "/project_type", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiResponse(code = 200, message = "成功为true,失败为false", response = WrappedResult.class)
    public WrappedResult<String> getProjectType(@RequestParam(value = "projectId",required = false) Long projectId,@RequestParam("pid") Long pid,@RequestParam("categoryIndex") String categoryIndex) {
        return WrappedResult.success(projectService.getProjectType(projectId,pid,categoryIndex));
    }

}
